<div class="row-fluid clearfix">
    <div class="col-md-12 column">
        <ul class="breadcrumb">
            <li>
                <a href="index.html">首页</a>
            </li>
            <li class="active">
                用户菜单分配管理
            </li>
        </ul>
    </div>
    <div class="col-md-12 column">
        <div class="col-sm-12 div-page">
            <div class="col-sm-12 div-table">
                <div id="custom-toolbar">

                </div>
                <table id="table" class="table table-hover table-condensed" data-toolbar="#custom-toolbar"
                       data-click-to-select="true"  data-single-select="true" data-height="450">
                    <thead>
                    <tr>
                        <th data-field="state" data-checkbox="true" ></th>
                        <th data-field="Dic_name" data-halign="center" data-align="center">商户类型</th>
                        <th data-field="IsMenuId" data-halign="center" data-align="center">是否已分配菜单</th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="col-sm-12 alert alert-success div-alert" id="events-result" data-es="Aquí se muestra el resultado del evento"></div>
    </div>
</div>

<script>
    $(function () {
        var rowData=null;

        var btnHtml ;
        var btnRole = JSON.parse($.cookie("Role_note"));

        btnHtml = '<div class="form-inline" role="form">';
        btnHtml += (btnRole["CommonDataModify"]) ? '<button id="btn-CommonDataModify" type="button" role="button" class="btn btn-sm btn-Data btn-success disabled">' +
                '<span class="glyphicon glyphicon-pencil"></span> 修改</button> ' : '' ;

        $("#custom-toolbar").append(btnHtml);

        $('#table').bootstrapTable({
            url: globalUrl+'api/MenuUserType?page=1&rows=99',
            responseHandler:function(resp){
                return resp.data.rows;
            },
            pagination:false,
            pageSize:5,
            search:true,
            pageList:[1,5,10]
        })
                .on('click-row.bs.table', function (e, row, $element) {
                    if ( $element.hasClass('selected') ) {
                        $element.removeClass('info');
                    }
                    else {
                        $element.parent('tbody').find(' > tr.selected ').removeClass("info");
                        $element.addClass('info');
                    }
                })
                .on('check.bs.table', function (e, row, $element) {
                    rowData=row;
                    $(".btn-Data").removeClass("disabled");
                })
                .on('uncheck.bs.table', function (e, row, $element) {
                    rowData=null;
                    $(".btn-Data").addClass("disabled");
                });
        //编辑按钮数据传递
        $('#btn-CommonDataModify').on("click",function () {
            console.log(rowData.Dic_data);
            localStorage.Dic_data=rowData.Dic_data;

            $.ajax({
                type: "get",
                url: 'MenuInfo/MenuInfoAllot.html',
                dataType: "html",
                success: function (result) {
                    $(".main-body").html(result);
                }
            });
        });
    });
    ///表格事件/////////////////////////////////////////////////////
    function rowStyle(row, index) {
        var classes = ['success', 'error'];
        if (index % 2 == 0) {
            return {
                classes: classes[0]
            };
        }
        return {
            classes: classes[1]
        };
    }

</script>